package cn.flant.io;

import java.util.Scanner;

import cn.flant.io.udp.HandlerPolicy;
import cn.flant.io.udp.HandlerPolicy.UnionType;
import cn.flant.io.udp.SocketHandler;
import cn.flant.io.udp.UdpServer;
import cn.flant.log.Logger;

public class MyUdpServer extends UdpServer {

	public MyUdpServer(int port) {
		super(port, MyUdpSocketHandler.class, new HandlerPolicy(UnionType.UNION_BY_HOSTIP, 10000));
	}

	public static void main(String[] args) {
		Logger.setDefaultLevel(Logger.DEBUG);
		MyUdpServer server = new MyUdpServer(1213);
		server.startup();
		Scanner scanner = new Scanner(System.in);
		String line = null;
		while ((line = scanner.nextLine()) != null) {
			for(SocketHandler handler : server.getSocketHandlers()) {
				handler.sendMessage(line);
			}
		}
	}

}
